import 'package:cbec_app/components/base/base_ctr.dart';
import 'package:cbec_app/components/http/network.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

import '../../routes/routes.dart';

///开屏广告页控制器
class SplashController extends BaseController {
  ///开屏广告配置
  Map<String, dynamic> config = {};
  @override
  void onInit() async {
    super.onInit();
    await getSplashAd();
    update();
  }

  ///获取开屏广告
  Future getSplashAd() async {
    return await Network.getSplashAd().then((value) {
      if (value != null) {
        config = value;
      } else {
        Get.offAllNamed(Routes.main);
      }
    });
  }
}
